package webui import ( "fmt" "github.com/jackc/pgx/v5/pgtype" "github.com/pogo-vcs/pogo/db" "github.com/pogo-vcs/pogo/server/webui/components" "strconv" "time" ) func formatDuration(start, finish pgtype.Timestamptz) string { if !start.Valid || !finish.Valid { return "N/A" } duration := finish.Time.Sub(start.Time) if duration < time.Second { return fmt.Sprintf("%dms", duration.Milliseconds()) } if duration < time.Minute { return fmt.Sprintf("%.1fs", duration.Seconds()) } if duration < time.Hour { return fmt.Sprintf("%.1fm", duration.Minutes()) } return fmt.Sprintf("%.1fh", duration.Hours()) } func formatTime(ts pgtype.Timestamptz) string { if !ts.Valid { return "N/A" } return ts.Time.Format("2006-01-02 15:04:05 MST") } templ CIRuns() { if repoId, ok := GetParamI32(ctx, "id"); ok { if repo, err := db.Q.GetRepository(ctx, repoId); err == nil { {{ hasAccess := repo.Public }} if !hasAccess && IsLoggedIn(ctx) { if user := GetUser(ctx); user != nil { if accessCheck, err := db.Q.CheckUserRepositoryAccess(ctx, repoId, user.ID); err == nil { {{ hasAccess = accessCheck }} } } } if hasAccess { @layout(repo.Name + " - CI Runs") { @components.Header(GetUser(ctx)) @components.Main() {

{ repo.Name } / CI Runs

if runs, err := db.Q.ListCIRuns(ctx, repoId); err == nil { if len(runs) == 0 {

No CI runs found for this repository.

} else {
for _, run := range runs { }
Status Event Rev Task Type Config Started Duration
if run.Success { ✓ Success } else { ✗ Failed } { run.EventType } { run.Rev } { run.TaskType } { run.ConfigFilename } { formatTime(run.StartedAt) } { formatDuration(run.StartedAt, run.FinishedAt) } View
} } else {

Failed to load CI runs: { err.Error() }

} } } } else { @layout("Unauthorized") { @components.Header(GetUser(ctx)) @components.Main() {

Access Denied

You don't have permission to view this repository.

} } } } } }